package com.myapp.ruyixing.http;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

import com.myapp.ruyixing.model.Reserve;

public class ReserveParser extends RYJSONParser {
	@Override
	public Object parse(JSONObject jsonObject) {

		Reserve reserve = new Reserve();
		ModelParser.parseModel(reserve, jsonObject);

		JSONObject data = jsonObject.optJSONObject("data");
		reserve.orderserve = data.optString("orderserve");
		reserve.shopname = data.optString("shopname");
		JSONArray array = data.optJSONArray("items");
		reserve.items = new ArrayList<String>();
		for (int i = 0; array != null && i < array.length(); i++) {
			String item = array.optString(i);
			reserve.items.add(item);
		}

		return reserve;

	}
}
